// component/music/music_lyric/music_lyric.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        Lyric: {
            type: Array,
            value: []
        },
        currentTime: {
            type: Number,
            value: 0
        },
        duration: {
            type: Number,
            value: 0
        },
        isPlaying: {
            type: Boolean,
            value: false,
        },
        musicUrl: {
            type: String,
            value: ""
        }
    },

    /**
     * 组件的初始数据
     */
    data: {
        isShowLyric: false,
        active: 0,
    },
    /**
     * 组件的方法列表
     */
    methods: {
        change(e) {
            console.log("event", e.detail.value)
            this.triggerEvent("GotoSeekTime", e.detail.value)
        },
        onChange(event) {
            wx.showToast({
                title: `切换到标签 ${event.detail.name}`,
                icon: 'none',
            });
        },
        onclick(e) {
            this.setData({
                isShowLyric: true
            })
            console.log("onclickasdf", e)
        },
        pre(e) {
            console.log("pre", e)
            this.triggerEvent("playPre")
        },
        play(e) {
            console.log("pre", e)
            this.triggerEvent("playCurrentMusic")
            // this.setData({
            //     isPlaying:true
            // })
        },
        pause(e) {
            console.log("pre", e)
            this.triggerEvent("pauseMusic")
            // this.setData({
            //     isPlaying:false
            // })
        },
        next(e) {
            console.log("next", e)
            this.triggerEvent("playNext")
        },

        back(e) {
            this.setData({
                isShowLyric: false
            })
            this.triggerEvent("onClose")
            // console.log(e)
        },
        downLoad(e) {
            console.log(e.currentTarget.dataset.musicurl)

            wx.setClipboardData({
                data: e.currentTarget.dataset.musicurl,
                success(res) {
                    wx.getClipboardData({
                        success(res) {
                            console.log(res.data) // data
                            wx.showToast({
                                title: '获得链接后浏览器打开',
                                duration:1500
                            })
                        }
                    })
                }
            })
        }
    }
})